<?php

include('udnutil.php');
//save to db
$con = udnutil::open_connection();

if($_GET['clear'] == 'search')
{
    mysql_query("DELETE FROM cache WHERE id LIKE '%udnsearch%'");
}
elseif($_GET['clear'] == 'movie')
{
    mysql_query("DELETE FROM cache WHERE id LIKE '%tt%'");
}
elseif($_GET['clear'] == 'person')
{
    mysql_query("DELETE FROM cache WHERE id LIKE '%nm%'");
}
else //clear all
{
    mysql_query("DROP TABLE `cache`;");

    mysql_query("
    CREATE TABLE `cache` (
      `id` varchar(500) NOT NULL,
      `body` blob NOT NULL,
      `dt` timestamp NOT NULL default CURRENT_TIMESTAMP,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    ");

    mysql_query("CREATE TABLE `ip` (
      `ip` varchar(20) NOT NULL,
      `id` smallint(6) NOT NULL auto_increment,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;");
}
udnutil::close_connection($con);
?>